<?php
$loader->requireOnce("includes/WorkingCalendar.class.php");     
/**
 * Controller Calendar actions
 */
class C_Calendar extends Controller {

    function C_Calendar ($template_mod = "general") {
        parent::Controller();
        $this->_db = $GLOBALS['frame']['adodb']['db'];   
    	if (Celini::getCurrentController() == 'Calendar') {
			$menu =& Menu::getInstance();
			$menu->currentSection = 'patient';
		}
        $this->template_mod = $template_mod;        
        $this->view->path = 'calendar';
    } 

 	public function actionViewCalendar() {
 		$person_list = Celini::newORDO('CalendarRelationship')->getRelationalUser($this->_me->get_person_id());
 		$this->assign('person_list', $person_list);
 		$person_name = $this->_me->get_person_name();
 		$this->assign('person_name', $person_name);
 		return $this->view->render("view.html");
 	}
 	
 	public function actionRenderMonth() {
 		$date = getdate();
 		$wc = new WorkingCalendar($date['year'], $date['mon']); 
 		return $wc->viewMonth($this->_me->get_person_id(), $_GET['year'], $_GET['month']);
 	}
 	
	public function actionRenderWeek() {
 		$date = getdate();
 		$wc = new WorkingCalendar($date['year'], $date['mon'], $date['mday']); 
 		return $wc->viewWeek($this->_me->get_person_id(), $_GET['year'], $_GET['month'], $_GET['day']);
 	}
 	
	public function actionRenderDay() {
 		$date = getdate();
 		$wc = new WorkingCalendar($date['year'], $date['mon'], $date['mday']); 
 		return $wc->viewDay($this->_me->get_person_id(), $_GET['year'], $_GET['month'], $_GET['day']);
 	}
 	
 	public function actionGetDetailOfEventAjax(){
 		$event_array = Celini::newORDO('CalendarEvent')->getEvent($_GET['eventId']);
		$user_list = Celini::newORDO('CalendarEventMap')->getUsers($_GET['eventId']);
		$event = $event_array[0];
		$this->assign('event', $event);
		$this->assign('user_list', $user_list);
		return $this->view->render("view_detail_of_event.html");
 		
 	}
    
}
?>